﻿using System;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace SchemaGeneration
{
    class Program
    {
        static void Main()
        {
            try
            {
                Configuration cfg = new Configuration().Configure();

                SchemaExport schema = new SchemaExport(cfg).SetOutputFile("create.sql");

                schema.Execute(false, false, false);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
                Console.Out.WriteLine(ex.StackTrace);

                Exception inner = ex.InnerException;
                while (inner != null)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine(inner.Message);
                    Console.Out.WriteLine(inner.StackTrace);

                    inner = inner.InnerException;
                }
            }
            finally
            {
                Console.Out.WriteLine("Finished!");
                Console.In.Read();
            }
        }
    }
}
